package com.vf.admin.client.service.impl;

import com.vf.admin.client.dao.AppMingXiZuanShiDao;
import com.vf.admin.client.dao.AppUserDao;
import com.vf.admin.client.service.AppMingXiZuanShiService;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppMingXiZuanShi;
import com.vf.admin.miaodong.entity.AppUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author anxiang
 * @version 1.0.0
 * @ClassName AppMingXiZuanShiServiceImpl.java
 * @Description TODO
 * @createTime 2021年11月02日 14:37:00
 */
@Service
public class AppMingXiZuanShiServiceImpl implements AppMingXiZuanShiService {


    @Autowired
    AppMingXiZuanShiDao appMingXiZuanShiDao;

    @Autowired
    AppUserDao appUserDao;

    @Override
    public void saveOrUpdate(AppMingXiZuanShi appMingXiZuanShi) {
        appMingXiZuanShiDao.saveOrUpdate(appMingXiZuanShi);
    }


    @Override
    public void addMingxi(Integer userid, BigDecimal num, Integer leixing, String beizhu) {
        AppUser user=appUserDao.get(userid);
        AppMingXiZuanShi zuanShi=new AppMingXiZuanShi();
        zuanShi.setUserid(user.getId());
        zuanShi.setPic(user.getPic());
        zuanShi.setPhone(user.getLoginname());
        zuanShi.setNick(user.getNick());
        zuanShi.setLeixing(leixing);
        zuanShi.setNum(num);
        zuanShi.setCreatetime(new Date());
        zuanShi.setBeizhu(beizhu);
        appMingXiZuanShiDao.saveOrUpdate(zuanShi);
    }

    @Override
    public List<AppMingXiZuanShi> findList(Integer userid, SplitPageBean splitPageBean) {
        return appMingXiZuanShiDao.findList(userid, splitPageBean);
    }

    @Override
    public List<AppMingXiZuanShi> listAfter(Map<String, Object> params) {
        return appMingXiZuanShiDao.listAfter(params);
    }
}
